<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('古汉语审核列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>文字：</p>
                                <input type="text" name="text"/>
                            </li>
                            <li>
                                <p>审核状态：</p>
                                <select name="approveSt" th:with="type=${@dict.getType('common_approve_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('dict:guhanyuapprove:edit')}]];
        var removeFlag = [[${@permission.hasPermi('dict:guhanyuapprove:remove')}]];
        var approveStDatas = [[${@dict.getType('common_approve_status')}]];
        var prefix = ctx + "dict/guhanyuapprove";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "古汉语审核",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'id',
                    visible: false
                },
                {
                    field : 'kkid', 
                    title : 'kkid'
                },
                {
                    field : 'text', 
                    title : '文字'
                },
                {
                    field : 'content', 
                    title : '内容'
                },
                {
                    field : 'createdTime', 
                    title : '提交时间'
                },
                {
                    field : 'ip', 
                    title : '提交者ip'
                },
                {
                    field : 'approveSt', 
                    title : '审核状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(approveStDatas, value);
                    }
                },
                {
                    field : 'approveUser', 
                    title : '审核用户'
                },
                {
                    field : 'approveTime', 
                    title : '审核时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.approveSt == 0){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="approve(\'' + row.id + '\', 1)"><i class="fa fa-edit"></i>审核通过</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="approve(\'' + row.id + '\', -1)"><i class="fa fa-remove"></i>审核不通过</a> ');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /* 审核 */
		function approve(id, status) {
			$.modal.confirm(status==1?'确定审核通过该解释吗?':'确定审核不通过该解释吗?', function() {
				$.operate.post(prefix + "/approve", { "id": id, "status": status });
		    })
		}

		function edit(id){
            var title = "编辑汉语解释"
            var url = $.table._option.updateUrl.replace("{id}", id);
            var width = 800;
            var height = ($(window).height() - 50);
            var index = layer.open({
                type: 2,
                area: [width + 'px', height + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: title,
                content: url,
                btn: ['审核入库', '确定', '关闭'],
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.approveHandler(index, layero);
                },
                btn2: function(index, layero){
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });
            layer.full(index);
		}


    </script>
</body>
</html>